<!DOCTYPE HTML>
<html>
  <head>
    <title>单双引号转换</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="shortcut icon" href="/WX-PLATFORM/resources/images/favicon2.ico">
	<script type="text/javascript" src="../js/jquery-1.11.1.min.js"></script>
	<style type="text/css">
		body{font-size: 12px;background:#F0F1F0;}
		.title{ font-family: 微软雅黑;color: #FF9800;font-size: 18px;line-height:3em; font-weight:bolder; }
		/*textarea {width:99%;height:180px;margin: 4px;}*/
		textarea {margin:10px 0;padding-top: 10px;font-size: 16px;outline: none;text-indent:1em;width:80%; height:15em; display:block; background:#fff;border:1px solid #FF9800; }
		label {cursor: pointer;color:#088A13;}
		.convertbtn{ outline:none; margin:1% 1% 0 0; cursor:pointer;  border:1px solid #FF9800;background:#fff;color:#FF9800;padding:5px 10px;font-family:微软雅黑;font-size:16px;}
		.footer{ text-align:center;padding:20px 0;font-size:16px;}
	</style>
  </head>
  
  <body>
  	<div class="title">HTML单双引号转换</div>
    <textarea id="tm-source"></textarea>
    <div>
    	<label><input type="radio" name="type" value="2">双引号转单引号</label>
    	<label><input type="radio" name="type" value="1" checked="checked">单引号转双引号</label>
    </div>
   <div>
   		 <label><input class="convertbtn" type="button" onclick="tm_transfter()" value="开始转换"></label>
   </div>
    <div>
    	<textarea id="tm-target"></textarea>
    <textarea id="tm-result"></textarea>
    </div>
    <script type="text/javascript">
    	function tm_transfter(){
    		var source = $.trim($("#tm-source").val().replace(/(\n)*$/,""));
    		var checkVal = $("input[type='radio']:checked").val();
	    	var result = "$('#xxxx').append(";
    		if(checkVal==2){
    			$("#tm-target").val(source.replace(/"/g,"'"));
    			var arr = $("#tm-target").val().match(/^(.*\n*)$/igm);
	    		for(var i=0;i<arr.length;i++){
	    			result += '"'+arr[i]+'"+\n';
	    		}
	    		$("#tm-result").val(result.substring(0,result.length-2)+");");
    		}
    		if(checkVal==1){
    			$("#tm-target").val(source.replace(/'/g,'\"'));
    			$("#tm-target").val(source.replace(/"/g,"\\\""));
	    		var arr = $("#tm-target").val().match(/^(.*\n*)$/igm);
	    		for(var i=0;i<arr.length;i++){
	    			result+='"'+arr[i].replace(/\s*/,'')+'"'+"+"+'\n';
	    		}
	    		$("#tm-result").val(result.substring(0,result.length-2)+");");
    		}
    	}
    </script>
    <div class="footer" style="color:#C7C4C4;">@Tony - 陕西西安高新区...</div> 
  </body>
</html>
